From 56a7a7851b09cb30a5cd543c8cb4f926109b4290 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 24 May 2026 13:22:34 +0000 Subject: refactor(locale): move hardcoded UI strings into english locale Adds optional namespaces (common, errors, commandPalette, headTitle, notifications, schedule, events, home, reader, routes, badgePreview, badgeWall) and extends existing ones (settings.*, lists.*, tools.*, user.*, hololive.*) on the Locale interface. New fields are optional so japanese.ts can omit them; svelte-i18n's fallbackLocale handles the runtime miss. HeadTitle gains an optional routeKey prop for type-safe lookup. defaultActions becomes a factory so the command palette re-reads locale on language toggle. The existing JP feedback translation in routes/settings is preserved via japanese.ts. Out of scope (kept hardcoded): service-worker.ts, app.html, Landing*.svelte, tools.ts registry, Easter Event 2025 pages. --- src/routes/user/[user]/+page.svelte | 45 +++++++------ src/routes/user/[user]/badges/+page.svelte | 103 ++++++++++++++++------------- 2 files changed, 82 insertions(+), 66 deletions(-) (limited to 'src/routes/user/[user]') diff --git a/src/routes/user/[user]/+page.svelte b/src/routes/user/[user]/+page.svelte index 1bcedc52..bfcdd87b 100644 --- a/src/routes/user/[user]/+page.svelte +++ b/src/routes/user/[user]/+page.svelte @@ -237,27 +237,29 @@ const toggleCategory = () => { // 8.5827814569536423841e0 - + {#if error} - @{data.username}'s - profile could not be loaded. + @{data.username}{$locale().errors?.profileCouldNotBeLoaded?.split('@{username}')[1]} {:else} {#if userData === null}

- Could not load user profile for @{data.username}. + >{$locale().user.profile.notLoaded?.split('@{username}')[1]}

{:else if userData === undefined} - + {:else}
{ {#if userData && authorisedUsers.includes(userData.id)} ‌ - + {/if} - Badge Wall + {$locale().user.profile.badgeWallLink}

{#if preferences && preferences.biography && preferences.biography.length > 0} @@ -362,7 +364,7 @@ const toggleCategory = () => { >
- +
@@ -401,7 +403,7 @@ const toggleCategory = () => { - Pinned Categories + {$locale().user.profile.pinnedCategories}
{#each ownerPreferences.pinned_badge_wall_categories as category} @@ -423,23 +425,28 @@ const toggleCategory = () => { {$locale().common?.remove}
{/each} - + - +
- Biography + {$locale().user.profile.biography} {$locale().common?.save} - Badge Wall Custom CSS + {$locale().user.profile.badgeWallCustomCss} {$locale().common?.save} {/if} diff --git a/src/routes/user/[user]/badges/+page.svelte b/src/routes/user/[user]/badges/+page.svelte index 9ff81118..de55b456 100644 --- a/src/routes/user/[user]/badges/+page.svelte +++ b/src/routes/user/[user]/badges/+page.svelte @@ -12,6 +12,7 @@ import { } from "$lib/Utility/time"; import proxy from "$lib/Utility/proxy"; import locale from "$stores/locale"; +import { get } from "svelte/store"; import Skeleton from "$lib/Loading/Skeleton.svelte"; import Message from "$lib/Loading/Message.svelte"; import Dropdown from "$lib/Layout/Dropdown.svelte"; @@ -209,7 +210,9 @@ type GroupedBadges = { [key: string]: IndexedBadge[] }; const setShadowHide = () => { if (!badger) { - loadError = "Something went wrong. Try refreshing."; + loadError = + get(locale)().badgeWall?.page?.somethingWentWrong ?? + "Something went wrong. Try refreshing."; return; } @@ -547,7 +550,9 @@ const shadowHideBadge = () => { if (!selectedBadge && !authorised) return; if (!badger) { - loadError = "Something went wrong. Try refreshing."; + loadError = + get(locale)().badgeWall?.page?.somethingWentWrong ?? + "Something went wrong. Try refreshing."; return; } @@ -561,7 +566,10 @@ const shadowHideBadge = () => { }; - + {#if loadError} @@ -571,11 +579,11 @@ const shadowHideBadge = () => { {@const isOwner = $identity && (isId ? $identity.id : $identity.name) === data.username} {#if $BadgeWallUser.fetching || !$BadgeWallUser.data} - + {:else if !$BadgeWallUser.data.User} - + {:else} {@const ungroupedBadges = castBadgesToIndexedBadges($BadgeWallUser.data.User.badges)} {@const isBadgeSelected = @@ -591,7 +599,7 @@ const shadowHideBadge = () => { {/if} {#if ungroupedBadges === null} - + {:else} @@ -605,23 +613,17 @@ const shadowHideBadge = () => { {#if shadowHidden}
- Notice: The Badge Wall overseer system has detected badges containing - AI-generated material on your wall. {shadowHiddenCount} of your badges have been shadow - hidden. + {$locale().badgeWall?.page?.notice} + {$locale({ values: { count: shadowHiddenCount } }).badgeWall?.page?.shadowHideNotice1} - You may use the "Un-shadow Hide Badges" button to unhide these badges, from where you will - be required to use the hide feature to hide these badges from the public, while allowing - them to stay visible to you as the account holder. + {$locale().badgeWall?.page?.shadowHideNotice2}
{:else if false && !noticeDismissed}
- Notice: AniList has begun purging outbound links which contain AI-generated - material, this includes Badge Wall. If you have collected badges with AI-generated - elements, kindly use the hide feature to hide these badges from the public, while - allowing them to stay visible to you as the account holder. + {$locale().badgeWall?.page?.notice} + {$locale().badgeWall?.page?.aiNotice1} - Failure to comply with this request at your earliest convenience will result in the hiding - of all badges from your Badge Wall. + {$locale().badgeWall?.page?.aiNotice2}
{/if} @@ -639,7 +641,7 @@ const shadowHideBadge = () => {
{#if authorised} - + {/if} {#if isOwner && authorised} @@ -675,7 +677,7 @@ const shadowHideBadge = () => { migrateMode = !migrateMode; }} > - Migrate Category + {$locale().badgeWall?.page?.migrateCategory} {#if shadowHidden} - + {/if} {#if editMode && isOwner} @@ -784,7 +786,7 @@ const shadowHideBadge = () => { ? dateToInputTime(databaseTimeToDate(selectedBadge.time)) : ''} /> - Must be full date and time, defaults to now if any fields empty + {$locale().badgeWall?.page?.dateTimeHint} @@ -827,13 +829,17 @@ const shadowHideBadge = () => { ({ - name: hidden ? 'Hidden' : 'Shown', + name: hidden + ? ($locale().badgeWall?.page?.hidden ?? 'Hidden') + : ($locale().badgeWall?.page?.shown ?? 'Shown'), url: '#', onClick: () => { const hiddenInput = document.querySelector('input[name="hidden"]'); if (hiddenInput instanceof HTMLInputElement) - hiddenInput.value = hidden ? 'Hidden' : 'Shown'; + hiddenInput.value = hidden + ? ($locale().badgeWall?.page?.hidden ?? 'Hidden') + : ($locale().badgeWall?.page?.shown ?? 'Shown'); } }))} header={false} @@ -842,16 +848,16 @@ const shadowHideBadge = () => { @@ -879,9 +885,11 @@ const shadowHideBadge = () => { {#if loadQueryParameter === 'none'}
- Notice: - {ungroupedBadges.length} badges have been loaded successfully, but they are not being displayed - due to your preferences (load=none). + {$locale().badgeWall?.page?.notice} + {$locale({ + values: { count: ungroupedBadges.length } + }).badgeWall?.page?.loadNoneNoticePrefix}load=none{$locale().badgeWall + ?.page?.loadNoneNoticeSuffix}
{:else} { {#if authorised} {/if} @@ -1026,13 +1036,13 @@ const shadowHideBadge = () => { {/if} (migrateMode = false)} show={migrateMode}> - Migrate Category + {$locale().badgeWall?.page?.migrateCategory} { /> - Leave category empty to migrate all to or from uncategorised. + {$locale().badgeWall?.page?.migrateAllHint} @@ -1060,29 +1070,28 @@ const shadowHideBadge = () => { {$locale().user.badges.importMode.cancel} (hideMode = false)} show={hideMode}> - Hide Category + {$locale().badgeWall?.page?.hideCategory} - If the majority of the badges in a category are shown, the category will be hidden, and vice - versa. + {$locale().badgeWall?.page?.hideVisibilityHint} - Leave category field empty to hide all. + {$locale().badgeWall?.page?.hideAllHint} @@ -1096,6 +1105,6 @@ const shadowHideBadge = () => { {$locale().user.badges.importMode.cancel} {$locale().badgeWall?.page?.toggleVisibility} -- cgit v1.2.3